package com.ihighest.app.infox.activity;

import io.rong.imkit.RongIM;
import io.rong.imlib.model.Conversation.ConversationType;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.ihighest.app.common.base.AbstractActivity;
import com.ihighest.app.infox.R;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.controller.UMServiceFactory;
import com.umeng.socialize.controller.UMSocialService;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.sso.EmailHandler;
import com.umeng.socialize.sso.SmsHandler;
import com.umeng.socialize.sso.UMQQSsoHandler;

public class MainActivityText extends AbstractActivity implements OnClickListener {
	final UMSocialService mController = UMServiceFactory.getUMSocialService("com.umeng.share");
	private final String QQAPPID = "1104807457";
	private final String QQAPPkey = "Z4bkvUVJNtwmDvtK";
	private String TOKEN = "trjqEEydlLrkz4F766W0J1ESPvBFccFCBqEU86CDxiuYoBJuSKbCDH3OYhxh9heFL8sbD4aQmy8j1FORp6iCQA==";
	private TextView showCharlist, showContent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.infox_activity_main);
		findViewById(R.id.share).setOnClickListener(this);

		showCharlist = (TextView) findViewById(R.id.showCharlist);
		showCharlist.setOnClickListener(this);
		showContent = (TextView) findViewById(R.id.showContent);
		showContent.setOnClickListener(this);
		// 设置分享内容
		mController.setShareContent("友盟社会化组件（SDK）让移动应用快速整合社交分享功能，http://www.umeng.com/social");
		// 设置分享图片, 参数2为图片的url地址
		mController.setShareMedia(new UMImage(this, "http://www.umeng.com/images/pic/banner_module_social.png"));
		mController.getConfig().removePlatform(SHARE_MEDIA.RENREN, SHARE_MEDIA.DOUBAN);
		UMQQSsoHandler qqSsoHandler = new UMQQSsoHandler(MainActivityText.this, QQAPPID, QQAPPkey);
		qqSsoHandler.addToSocialSDK();
		// 添加短信
		SmsHandler smsHandler = new SmsHandler();
		smsHandler.addToSocialSDK();
		// 添加email
		EmailHandler emailHandler = new EmailHandler();
		emailHandler.addToSocialSDK();
		mController.getConfig().removePlatform(SHARE_MEDIA.QZONE);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.share:
			// 是否只有已登录用户才能打开分享选择页
			mController.openShare(MainActivityText.this, false);
			break;

		case R.id.showCharlist:
			// 回话列表界面
			RongIM.getInstance().startConversationList(MainActivityText.this);
			break;
		case R.id.showContent:
			// 回话内容界面
			RongIM.getInstance().startConversation(MainActivityText.this, ConversationType.PRIVATE, "jie", "title");

		default:
			break;
		}

	}

}
